package com.unreal.example.controller;

import com.unreal.example.bean.AccountInfo;
import com.unreal.example.service.AccountInfoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class AccountInfoController {    

    @Autowired
    private AccountInfoService service;

    @PostMapping("/save")
    public AccountInfo saveAccountInfo(AccountInfo accountInfo){
        return service.saveAccountInfo(accountInfo);
    }

    @PostMapping("/update")
    public long updateAccountInfo(AccountInfo accountInfo){
        return service.updateAccountInfo(accountInfo);
    }

    @GetMapping("/list")
    public List<AccountInfo> listAccountInfo(){
        return service.listAccountInfo();
    }

    @GetMapping("/info/{id}")
    public AccountInfo listAccountInfo(@PathVariable("id") String id){
        return service.getAccountInfoById(id);
    }
}